package com.datang.springcode.scanPack;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@ComponentScan(value = {"com.datang.springcode.scanPack"})
@Configuration(proxyBeanMethods = false)
public class ScanPackConfig {

    @Bean(value = "milk")
    public Milk getMilk() {
        //这种写法完全没有问题。构造函数需要一个Fruit而getFruit()方法返回的就是一个fruit
        return new Milk(getFruit());
    }

    @Bean(value = "fruit")
    public Fruit getFruit() {
        return new Fruit();
    }
}
